package com.xiaolun;

/**
 * @Author 硕鼠
 * @Date 2020/5/9 10:50
 * @Version 1.0
 * @Description 测试礼让线程
 */
public class TestYield {
    public static void main(String[] args) {
        MyYeild myYeild = new MyYeild();

        new Thread(myYeild,"a").start();
        new Thread(myYeild,"b").start();
    }
}

class MyYeild implements Runnable{

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"线程开始执行");
        Thread.yield(); //线程礼让
        System.out.println(Thread.currentThread().getName()+"线程停止执行");
    }
}